﻿using System.ComponentModel.DataAnnotations;

namespace FlyingHat.Model.Attribute.Model
{
    [AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = false)]
    public class RealNameAttribute : ValidationAttribute
    {
        public override bool IsValid(object? value)
        {
            if (value == null)
            {
                return false;
            }
            // 此处开始做验证，这里只做演示
            var val = value.ToString();
            if (!string.IsNullOrWhiteSpace(val) && val.Length > 50)
            {
                return false;
            }
            return true;
        }
    }
}
